import KoaRouter from 'koa-router'
import Mock from 'mockjs'

/**
 * 设备
 */
export interface IEquipment {
  id: number
  name: string
}

/**
 * 设备列表
 */
export interface IApiGetEquipmentList {
  data?: IEquipment[]
}

const router = new KoaRouter()

/**
 * @api {get} /equipment/list 获取设备列表
 * @apiName getEquipmentList
 * @apiGroup Equipment
 * @apiDescription 获取设备列表
 *
 * @apiSuccessExample {json} 获取成功
 *   HTTP/1.1 200 OK
 *   {
 *     "data": [
 *       {
 *         "id": 1,
 *         "name": "我的设备"
 *       },
 *       {
 *         "id": 2,
 *         "name": "公司测试"
 *       },
 *     ]
 *   }
 *
 * @apiSuccess {Object[]} data 列表数据
 * @apiSuccess {Number} data.id 设备ID
 * @apiSuccess {String} data.name 设备名
 */
router.get('getEquipmentList', '/list', ctx => {
  ctx.body = Mock.mock({
    'data|0-16': [
      {
        'id|1-9999999999': 1,
        name: '@ctitle(2,20)',
      },
    ],
  })
})

export default router.routes()
